using System;
using DevExpress.Xpo.DB;
using System.ServiceModel;
using Common;
using DevExpress.Xpo.DB.Helpers;

namespace Server
{
    /// <summary>
    /// DataStoreServerProxy
    /// </summary>
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class CachedDataStoreServerProxy : ICachedDataStoreContract
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="CachedDataStoreServerProxy"/> class.
        /// </summary>
        /// <param name="wrappedDataStore">The wrapped data store.</param>
        public CachedDataStoreServerProxy(ICachedDataStore wrappedDataStore)
        {
            this.wrappedCachedDataStore = wrappedDataStore;
        }

        ICachedDataStore wrappedCachedDataStore;

        #region IDataStoreContract Members

        AutoCreateOption ICachedDataStoreContract.GetAutoCreateOption()
        {
            return wrappedCachedDataStore.AutoCreateOption;
        }

        ModificationResult ICachedDataStoreContract.ModifyData(params ModificationStatement[] dmlStatements)
        {
            return wrappedCachedDataStore.ModifyData(dmlStatements);
        }

        SelectedData ICachedDataStoreContract.SelectData(params SelectStatement[] selects)
        {
            return wrappedCachedDataStore.SelectData(selects);
        }

        UpdateSchemaResult ICachedDataStoreContract.UpdateSchema(bool dontCreateIfFirstTableNotExist, params DBTable[] tables)
        {
            return wrappedCachedDataStore.UpdateSchema(dontCreateIfFirstTableNotExist, tables);
        }

        #endregion

        #region ICachedDataStoreContract Members

        DataCacheResult ICachedDataStoreContract.NotifyDirtyTables(DataCacheCookie cookie, params string[] dirtyTablesNames)
        {
            return wrappedCachedDataStore.NotifyDirtyTables(cookie, dirtyTablesNames);
        }

        DataCacheResult ICachedDataStoreContract.ProcessCookie(DataCacheCookie cookie)
        {
            return wrappedCachedDataStore.ProcessCookie(cookie);
        }

        DataCacheModificationResult ICachedDataStoreContract.ModifyDataCached(DataCacheCookie cookie, ModificationStatement[] dmlStatements)
        {
            return wrappedCachedDataStore.ModifyData(cookie, dmlStatements);
        }

        DataCacheSelectDataResult ICachedDataStoreContract.SelectDataCached(DataCacheCookie cookie, SelectStatement[] selects)
        {
            return wrappedCachedDataStore.SelectData(cookie, selects);
        }

        DataCacheUpdateSchemaResult ICachedDataStoreContract.UpdateSchemaCached(DataCacheCookie cookie, DBTable[] tables, bool dontCreateIfFirstTableNotExist)
        {
            return wrappedCachedDataStore.UpdateSchema(cookie, tables, dontCreateIfFirstTableNotExist);
        }

        #endregion
    }
}
